# -*- codeing = utf-8 -*-
# @Time: 2023/6/15 9:42
# @Author: caoyi
# @File: base_api.py
# @Software: PyCharm
import requests
import urllib3

BASE_URL = "https://litemall.hogwarts.ceshiren.com"
# 代理,因为使用抓包工具
proxys = {
    "http":"127.0.0.1:8888",
    "https":"127.0.0.1:8888"
}
# 忽略警告
urllib3.disable_warnings()

class BaseApi:

    def __init__(self,session = None):
        # 保存上下文能力，一次请求，之后不用
        # 当session为None的使用才进行初始化
        if session is None:
            self.session = requests.Session()
        else:
            self.session = session

    def myrequest(self,method,url,**kwargs):
        # 封装自定义的请求函数，传入代理配置
        return self.session.request(method=method,url=url,proxies = proxys,verify=False,**kwargs)

